package mybatis.main;

import static java.lang.System.out;

import java.io.Reader;

import mybatis.domain.User;
import mybatis.mapper.Mapper03;
import mybatis.mapper.Mapper07;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

//mapper07.xml, SqlMapConfig.xml
public class Main07 {	
	public static void main(String[] args) throws Exception{		
		Reader reader = Resources.getResourceAsReader("config/SqlMapConfig.xml");		
		SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);		
		SqlSession sqlSession = sqlSessionFactory.openSession();
		
		Mapper07 mapper = sqlSession.getMapper(Mapper07.class);
		Mapper03 getMapper = sqlSession.getMapper(Mapper03.class);		
				
		out.println("[updateUser]");
		mapper.updateUser(new User("u01",null,"정수정",null,null));
		sqlSession.commit();
	
		out.println("[getUser]");
		out.println(getMapper.getUser("u01"));		
	}
}